package cn.itcast.n4_共享模型_管程;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;

/**
 * @program: juc
 * @description: -XX:BiasedLockingStartupDelay=0
 * @author: flyduck
 * @create: 2024-09-25 16:09
 **/
@Slf4j(topic = "c.Test13_偏向锁状态_查看偏向锁加锁前后的状态变化")
public class Test13_偏向锁状态_查看偏向锁加锁前后的状态变化 {
    public static void main(String[] args) throws InterruptedException {
        Dog dog = new Dog();
        log.debug("加锁前对象的mark word:{}",ClassLayout.parseInstance(dog).toPrintableSimple());//00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000101

        synchronized (dog) {
            log.debug("加锁后对象的mark word:{}",ClassLayout.parseInstance(dog).toPrintableSimple());//00000000 00000000 00000000 00000000 00000010 10100010 00111000 00000101
        }

        log.debug("解锁后对象的mark word:{}",ClassLayout.parseInstance(dog).toPrintableSimple());//00000000 00000000 00000000 00000000 00000010 10100010 00111000 00000101
    }
}


